#include <iostream>
#include <vector>

using namespace std;

const int N = 2e6 + 10;
 
vector<int> a(N);
int n, m;

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= m; i++)
	{
		int x; cin >> x;
		cout << a[x] << "\n";	
	}
	
	return 0;
}
